package com.hlw.hr_man.serviceImpl;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.hlw.hr_man.Model.EmployeeModel;
import com.hlw.hr_man.dao.EmployeeDao;
import com.hlw.hr_man.dao.FindCardDao;
import com.hlw.hr_man.daoImpl.FindCardDaoImpl;
import com.hlw.hr_man.service.FindCardService;

/**
 * 名片夹服务实现类
 * @author qiyu
 *
 */
public class FindCardServiceImpl implements	FindCardService{
	FindCardDao edao = new FindCardDaoImpl();
	@Override
	public JSONObject getEmployee(int start, int pageSize, String searchName) {
		JSONObject emps = new JSONObject();
		emps.put("total", edao.getEmpsCount(searchName));
		emps.put("rows", JSONArray.fromObject(edao.getEmps(start, pageSize, searchName)));
		return emps;
	}
	@Override
	public JSONObject getEmployee(int e_id,int start, int pageSize) {
		JSONObject emps = new JSONObject();
		emps.put("total", 1);
		emps.put("rows", JSONArray.fromObject(edao.getEmps(e_id, start, pageSize)));
		return emps;
	}
	@Override
	public JSONObject getCardCase(int id) {
		JSONObject cards = new JSONObject();
		cards = JSONObject.fromObject(edao.getCardCase(id));
		return cards;
	}
	@Override
	public int addCard(EmployeeModel e) {
		// TODO Auto-generated method stub
		return edao.addCard(e);
	}
	@Override
	public boolean isHaveCard(int e_id) {
		// TODO Auto-generated method stub
		return edao.findCardByE_id(e_id);
	}
	@Override
	public int deleteCard(int e_id) {
		// TODO Auto-generated method stub
		return edao.deleteCard(e_id);
	}
	@Override
	public int updataStudent(EmployeeModel e) {
		// TODO Auto-generated method stub
		return edao.updateCard(e);
	}
	@Override
	public JSONObject findEmployee(int start, int pageSize, String searchtype) {
		// TODO Auto-generated method stub
		JSONObject emps = new JSONObject();
		emps.put("total", edao.findEmpsCount(searchtype));
		emps.put("rows", JSONArray.fromObject(edao.findEmps(start, pageSize, searchtype)));
		return emps;
	}
}
